import importlib
import os
import pkgutil
# 遍历包中的所有模块
import sys

path=__path__
for _, module_name, _ in pkgutil.iter_modules(path):
    # 动态导入每个模块
    importlib.import_module(f".{module_name}", package=__name__)

# package_dir = os.path.dirname(__file__)
# for _, module_name, _ in pkgutil.iter_modules([package_dir]):
#     if module_name not in sys.modules:
#         try:
#             importlib.import_module(f".{module_name}", package=__name__)
#             print(f"Imported module {module_name}")
#         except Exception as e:
#             print(f"Failed to import module {module_name}: {e}")
